package com.springmvc.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.source.common.dao.BaseDao;

@Controller
@RequestMapping(value = "/app/hello")
public class HelloAction {
	
	@Autowired
	private BaseDao baseDao;
	
	@RequestMapping(value="/index", method = {RequestMethod.GET})
	public ModelAndView index() throws Exception {
		ModelAndView modelAndView = new ModelAndView();
		List list = baseDao.queryList("select * from base_building_info");
		modelAndView.addObject("list", list);
		modelAndView.addObject("message", "index 的视图页面");  
       //modelAndView.setViewName("index"); 
		return modelAndView;
	}
	
	@RequestMapping(value="/say", method = {RequestMethod.GET})
	public ModelAndView sayHello() {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("message", " 你好!"); 
		Map map = new HashMap();
		map.put("a", 1);
		map.put("b", 2);
		modelAndView.addObject("message2", map); 
		modelAndView.getViewName();
		modelAndView.setViewName("app/hello/say2");
		return modelAndView;
	}
}
